package com.tenxcloud.zipkin.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

  @Autowired
  private JdbcTemplate jdbcTemplate;
  @Autowired
  private MessageSend messageSend;

  @GetMapping("/hi")
  public String hi() {
    String name = jdbcTemplate.queryForObject("SELECT current_time from dual", String.class);
    messageSend.add(name);
    return "Welcome " + name;
  }

//  @GetMapping("/https")
//  public String http() throws Exception {
//    Request request = new Request.Builder().url("http://localhost:9875/hello").build();
  //    Response response = client.newCall(request).execute();
//    return response.body().string();
//  }

  @GetMapping("/mq")
  public String mq() {
    String str = "bbb";
    messageSend.add(str);
    return "发送了信息 " + str;
  }
//  @org.springframework.amqp.rabbit.annotation.RabbitListener(queues = "zipkin")
//  private void handleMessage(Message message){
//    String messageBody = new String(message.getBody());
//    System.out.println("收到了消息是 : " + messageBody);
//  }
}
